<template>
<div class="bg">
    <div class="inner-1200 clear-fix">
        <div class="banner-nav f1">
            <ul class="banner-nav-ul flex">
                <li class="banner-nav-li" v-for="menu in menuList" @click="changeMenu(menu.id)" :class="{active:menuType===menu.id}" :key="menu.id">
                    <p>{{menu.name}}</p>
                </li>
            </ul>
        </div>
        <div class="book-list-box fr">
            <div class="book-list-div">
                <transition-group name="list">
                    <div v-for="book in books" :key="book.id" v-show="menuType===book.type"
                    class="book-1 f1" @click="goto(book.id)">
                        <div class="book-1-img cz-c f1">
                            <img class="f1" :src="geturl(book.image)">
                        </div>
                        <div class="fr book-1-info">
                            <h3 class="ellipsis">{{book.title}}</h3>
                            <p>主编:{{book.editor}}</p>
                            <p>出版社:{{book.press}}</p>
                            <p>适用层次:{{book.level}}</p>
                            <p>出版/修订日期:{{book.date}}</p>
                            <p>定价:{{book.price}}元</p>
                        </div>
                    </div>
                </transition-group>
            </div>
        </div>
    </div>
</div>
</template>
<script setup>
import menuList from '../assets/json/menu.json'
import books from '../assets/json/books.json'
import {ref} from 'vue'
import {useRouter} from 'vue-router'
const router = useRouter()
const menuType = ref(1)
const changeMenu = (id)=>{menuType.value = id}
const geturl = (url)=>{
    const url_ = new URL(url,import.meta.url).href
    console.log(url_)
    return url_
}
const goto = (id)=>{router.push('/book/'+id)}
</script>
<style scoped>
.list-enter-active,
.list-leave-active {
    transition: all 0.5s ease;
    /* position: absolute; */
}

.list-enter-from,
.list-leave-to {
    opacity: 0;
    transform: translateX(60px);
}

.bg {
    background: #f3f5f9;
    /* padding: 40px 0 20px; */
}

div {
    margin: 0 auto;
}

.nav-box {
    height: 60px;
    width: 1200px;
    user-select: none;
    padding: 0px;
}

.f1 {
    float: left;
}

.pcv1-book-title {
    margin-right: 60px;
}

img {
    border: none;
    vertical-align: middle;
    overflow: hidden;
    image-rendering: -moz-crisp-edges;
    image-rendering: -o-crisp-edges;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.nav-search {
    margin: 0;
    border: 0;
    width: 540px;
    height: 36px;
    -webkit-border-radius: 6px;
    -moz-border-radius: 6px;
    border-radius: 6px;
    background: #fff;
}

.nav-search input {
    margin: 4px 12px;
    width: 450px;
    line-height: 28px;
    border: none;
    outline: none;
    text-shadow: none;
    /* -webkit-appearance: none; */
    overflow: visible;
}

.a-mouse {
    cursor: pointer;
}

.fr {
    float: right;
}

.nav-search span {
    margin: 4px;
    width: 52px;
    height: 28px;
    font-size: 13px;
    line-height: 28px;
    -webkit-border-radius: 6px;
    -moz-border-radius: 6px;
    border-radius: 6px;
    background-color: #16CA82;
    color: #ffffff;
    padding-left: 2px
}

.clear-fix::after {
    content: "";
    display: block;
    height: 0;
    overflow: hidden;
    clear: both;
    visibility: hidden;
}

.inner-1200 {
    width: 1200px;
    margin: 0 auto;
}

.banner-nav {
    width: 230px;
}

.banner-nav-ul {
    box-sizing: border-box;
    padding: 4px 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    border-radius: 6px;
    flex-wrap: wrap;
    align-content: flex-start;
    position: relative;
}

.flex {
    display: flex;
    display: -webkit-flex;
    justify-content: flex-start;
    align-items: center;
}

.banner-nav-li {
    width: 100%;
    padding: 0 6px;
    margin: 0px;
    list-style: none;
}

.active {
    text-decoration: none;
    background: rgba(22, 202, 130, .1);
    color: #16ca82;
}

.banner-nav-li p {
    padding: 12px;
    text-align: center;
    line-height: 20px;
    background: transparent;
    box-sizing: border-box;
    width: 100%;
    font-size: 16px;
    font-weight: bold;
    border-radius: 6px;
    cursor: default;
    user-select: none;
    margin: 0;
}

.book-list-box {
    width: 960px;
    margin: 0px, auto;
    background: #fff;
    min-height: 800px;
    overflow: hidden;
}

.book-list-div {
    width: 100%;
    height: auto;
    padding-bottom: 8px;
    overflow: hidden;
    margin: 0px;
}

.book-1 {
    width: 410px;
    height: 180px;
    padding: 20px 15px;
    text-align: left;
    margin: 20px 0px 0px 20px;
}

.book-1-img {
    width: 148px;
    height: 180px;
    overflow: hidden;
}

.cz-c {
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-1-info {
    width: 252px;
    height: 180px;
    padding-left: 10px;
    overflow: hidden;
    margin: 0px;
}

.ellipsis {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.book-1-info h3 {
    font-size: 16px;
    margin: 0px;
    margin-bottom: 12px;

}

.book-1-info p {
    font-size: 13px;
    color: #555555;
    line-height: 22px;
    margin: 0px;
}

/* 浮动购物车 */
.fixed-r {
    position: fixed;
    top: 300px;
    right: 0;
    user-select: none;
    z-index: 100000;
    margin: 0px auto;
    padding: 0px;
}

.fixed-r-ul {
    margin-bottom: 10px;
    background: #fff;
    -webkit-box-shadow: 0 3px 10px 0 rgba(0, 0, 0, 0.1);
    -moz-box-shadow: 0 3px 10px 0 rgba(0, 0, 0, 0.1);
    box-shadow: 0 3px 10px 0 rgba(0, 0, 0, 0.1);
    -webkit-border-radius: 8px;
    -moz-border-radius: 8px;
    border-radius: 8px;
    margin: 0px auto;
    padding: 0px;
}

.fixed-r-ul li {
    box-sizing: initial;
    width: 84px;
    height: 68px;
    padding-top: 12px;
    text-align: center;
    line-height: 28px;
    font-size: 12px;
    position: relative;
    color: #333;
    list-style: none;
}

.fixed-r-ul li p {
    margin: 0px;
}

.car-sum {
    box-sizing: border-box;
    padding: 0 4px;
    min-width: 22px;
    height: 22px;
    line-height: 20px;
    text-align: center;
    -webkit-border-radius: 14px;
    -moz-border-radius: 14px;
    border-radius: 14px;
    background-color: #eb612a;
    color: #ffffff;
    display: block;
    font-size: 12px;
    position: absolute;
    left: 46px;
    top: 6px;
}

.fixed-r-icon-box {
    background: url(../assets/img/cart_icon_normal.png) center center no-repeat;
    background-size: 24px 24px;
    width: 30px;
    height: 30px;
    overflow: hidden;
}

.pcv1-before-login {
    width: 134px;
    margin: 0;
    float: right;
    text-align: center;
    justify-content: flex-end;
    border: 0;
    /* width: 540px; */
    height: 36px;
    -webkit-border-radius: 6px;
    -moz-border-radius: 6px;
    border-radius: 6px;
    background: #fff;
}

.pcv1-before-main {
    width: 134px;
    margin: 0;
    float: left;
    text-align: center;
    justify-content: flex-end;
    border: 0;
    /* width: 540px; */
    height: 36px;
    -webkit-border-radius: 6px;
    -moz-border-radius: 6px;
    border-radius: 6px;
    background: #fff;
    margin-right: 30px;
}

.pcv1-before-main span {
    margin-left: auto;
    margin-right: auto;
}

.flex {
    display: flex;
    display: -webkit-flex;
    justify-content: flex-start;
    align-items: center;
}

.pcv1-before-login span {
    margin-left: auto;
    margin-right: auto;
}
</style>